package com.easylinkin.linkappapi.keywork.utils;

import com.easylinkin.linkappapi.keywork.dto.SafeTableDto;
import com.easylinkin.linkappapi.keywork.entity.SafeTable;
import org.apache.commons.lang3.StringUtils;

public class EntityCheckUtils {

    public static String checkSafeTable(SafeTable safeTable){
        if (null == safeTable.getGridId()){
            return "请选择安全确认表所属网格";
        }
        if (null == safeTable.getKeyworkId()){
            return "请选择安全确认表所属作业内容";
        }
        if (null == safeTable.getWorkTime()){
            return "请填写施工时间";
        }
        if (StringUtils.isEmpty(safeTable.getTableName())){
            return "表名不能为空";
        }
        return null;
    }

    public static String checkSafeTableRecord(SafeTableDto safeTableDto){
        if (safeTableDto.getCheckOpinion() == 0){ //此时提交的是子项检查记录
            if (safeTableDto.getSafeTableRecordDtoList().size() == 0){
                return "检查项不能为空";
            }
        }
        return null;
    }
}
